from django.db import models
from django.conf import settings
import time;
import datetime
# Create your models here.
class Room(models.Model):
    id=models.AutoField(primary_key=True)
    floor=models.IntegerField(default=8)
    name=models.CharField(max_length=30,default="没有名字")
    permissions=models.IntegerField(default=0)
    maxFill=models.IntegerField(default=5)
    state=models.BooleanField(default=True)
    hasTv=models.BooleanField(default=False)
    hasTel=models.BooleanField(default=False)
    hasMv=models.BooleanField(default=False)

    def __str__(self):
        return str(self.id)+self.name+"楼层:"+str(self.floor)
class Department(models.Model):
    id=models.AutoField(primary_key=True)
    name=models.CharField(max_length=30,default="部门名字没有")
    def __str__(self):
        return self.name
class Employee(models.Model):
    id=models.AutoField(primary_key=True)
    name=models.CharField(max_length=30,default="没名字的家伙")
    permissions=models.IntegerField(default=0)
    floor=models.IntegerField(default=8)
    phone=models.IntegerField(default=17855847527)
    mail=models.CharField(max_length=30,default="guqianbin@myhexin.com")
    password=models.CharField(max_length=30,default="123456789")
    department = models.ForeignKey(Department, related_name="+", default=1)
    def __str__(self):
        return self.name

class roomBooking(models.Model):
    id=models.AutoField('主键id',primary_key=True)
    topic=models.CharField('会议名称',max_length=50,default="无")
    start=models.IntegerField('开始',default=1)
    end=models.IntegerField('结束',default=1)
    bookDate=models.DateField('会议日期',auto_now=False,null=True)
    empCount=models.IntegerField('参会人员',default=0)
    roomId=models.ForeignKey(Room,related_name='room_book')
    roomName=models.CharField('会议室名称',max_length=30,default="空")
    # empId=models.IntegerField(default=0)#申请员工的id
    empId=models.ForeignKey(Employee,related_name='+')
    empPswd=models.CharField(max_length=30,default="空")
    state=models.IntegerField('状态',default=0)#0表示创建待审核，1表示审核通过，2表示否定

    def __str__(self):
        return "房间id："+str(self.id)+"申请人id:"+str(self.empId)



class Floor(models.Model):
    id=models.AutoField(primary_key=True)
    floorNum=models.IntegerField(default=0)
    def __str__(self):
        return str(self.floorNum)
class MeetingEmp(models.Model):
    id=models.AutoField(primary_key=True)
    emp=models.ForeignKey(Employee,related_name='emp_meetings')
    roomBook=models.ForeignKey(roomBooking,related_name='book_emps',on_delete=models.CASCADE)
    room=models.ForeignKey(Room,related_name='+')
    meetDate=models.DateField('会议日期',auto_now=False,null=True)


